<template>
  <view class="container">
	<xk-header :headerbg="true" class="header" :back="true" title="楼栋洗手间"></xk-header>
	<view class="top-localtion">
		<u-row >
			<u-col span="8">
				所在楼栋选择
			</u-col>
			<u-col span="4">
				<u-button @click="showPk = true" size="small">{{xuanname}} <u-icon name="arrow-down" color="#2979ff" size="14" customStyle="margin-left:5px;"></u-icon></u-button>
			</u-col>
		</u-row>
		<u-picker :show="showPk" :columns="columns" @confirm="confirmPk" @cancel="showPk =false"></u-picker>
	</view>

	<block v-for="(item, index) in toiletList" :key="index">
		<view class="box1">
		<view class="loutitlebox" @click="gotoUrl" :data-url="'/pagesB/toilet/detail?lid='+item.id">
			<u-row >
				<u-col span="11">
					<view class="louinfo"><image class="louicon" mode="widthFix" :src="(imgUrl+'/wx/lou.png')" ></image> {{item.name}}</view>
				</u-col>
				<u-col span="1" textAlign="right">
					<view style="margin-left:10px;"><u-icon name="arrow-right" color="#999"></u-icon></view>
				</u-col>
			</u-row>
		</view>
		<u-row >
			<u-col span="5">
				<u-row >
					<u-col span="5">
						<view class="sexbox"><image class="sexicon" mode="widthFix" :src="(imgUrl+'/wx/male.png')" ></image></view>
					</u-col>
					<u-col span="7" textAlign="left">
						<view class="kongxian">空闲：{{item.manyou}}个</view>
						<view class="zhanwei">占位：{{item.manwu}}个</view>
					</u-col>
				</u-row>
			</u-col>
			<u-col span="1" offset="1"><view class="lineheight">1</view></u-col>
			<u-col span="5">
				<u-row >
					<u-col span="4">
						<view class="sexbox"><image class="sexicon" mode="widthFix" :src="(imgUrl+'/wx/female.png')" ></image></view>
					</u-col>
					<u-col span="8" textAlign="left">
						<view class="kongxian">空闲：{{item.nvyou}}个</view>
						<view class="zhanwei">占位：{{item.nvwu}}个</view>
					</u-col>
				</u-row>
			</u-col>
		</u-row>
		</view>
	</block>

	<view class="loadtext">
		<u-loadmore
			:line="true"
			loadingIcon="spinner"
			:status="status"
			:loading-text="loadingText"
			:loadmore-text="loadmoreText"
			:nomore-text="nomoreText"
		/>
	</view>
	<u-toast ref="uToast" />
  </view>
</template>

<script>
  /* import { setCartTabBadge } from '@/core/app'
  import * as Api from '@/api/page'
  import Page from '@/components/page' */

  const App = getApp()

  export default {
    components: {},
    data() {
      return {
		imgUrl:this.$config.BASE_imgUrl,
        // 页面参数
        options: {},
        // 页面属性
        page: {},
        // 页面元素
        items: [],
		xuanvalue:0,
		xuanname:'主楼',
		showPk:false,
		columns: [
			['主楼', '副楼']
		],
		toiletList:[
			{id:1,name:'1楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:2,name:'2楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:3,name:'3楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:4,name:'4楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:5,name:'5楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:6,name:'6楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:7,name:'7楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:8,name:'8楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:9,name:'9楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:10,name:'10楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:11,name:'11楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:12,name:'12楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:13,name:'13楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:14,name:'14楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:15,name:'15楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:16,name:'16楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:17,name:'17楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:18,name:'18楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
		],
		demoList0:[
			{id:1,name:'1楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:2,name:'2楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:3,name:'3楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:4,name:'4楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:5,name:'5楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:6,name:'6楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:7,name:'7楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:8,name:'8楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:9,name:'9楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:10,name:'10楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:11,name:'11楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:12,name:'12楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:13,name:'13楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:14,name:'14楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:15,name:'15楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:16,name:'16楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:17,name:'17楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
			{id:18,name:'18楼',sex:'男',manyou:3,manwu:5,sex2:'女',nvyou:5,nvwu:3},
		],
		demoList1:[
			{id:1,name:'1楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
			{id:2,name:'2楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
			{id:3,name:'3楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
			{id:4,name:'4楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
			{id:5,name:'5楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
			{id:6,name:'6楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
			{id:7,name:'7楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
			{id:8,name:'8楼',sex:'男',manyou:2,manwu:4,sex2:'女',nvyou:4,nvwu:2},
		],
		status: 'loading',
		loadingText: '加载更多数据',
		loadmoreText: '轻轻上拉加载',
		nomoreText: '没有更多的信息'
      }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      // 当前页面参数
      this.options = options
      // 加载页面数据
      //this.getPageData();
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
    },

    methods: {
	  gotoUrl(e){
		var weburl=e.currentTarget.dataset.url;
		//在起始页面跳转到test.vue页面并传递参数
		uni.navigateTo({
			url:weburl
		});
	  },
	  confirmPk(e){
		//console.log('confirm', e)
		var that=this;
		this.xuanname=e.value[0]
		var indexs=e.indexs[0]
		this.showPk=false;
		 this.$refs.uToast.show({
			type: 'loading',
			title: '正在加载',
			message: "正在加载",
			duration:1000,
			complete(){
				if(indexs==0){
					that.toiletList=that.demoList0;
					that.status='loading';
				}else{
					that.toiletList=that.demoList1;
					that.status='nomore';
				}
			}
		 });
	  },
      /**
       * 加载页面数据
       * @param {Object} callback
       */
      getPageData(callback) {
        const app = this
        const pageId = app.options.pageId || 0
        Api.detail(pageId)
          .then(result => {
            // 设置页面数据
            const { data: { pageData } } = result
            app.page = pageData.page
            app.items = pageData.items
            // 设置顶部导航栏栏
            app.setPageBar();
          })
          .finally(() => callback && callback())
      },

      /**
       * 设置顶部导航栏
       */
      setPageBar() {
        const {
          page
        } = this
        // 设置页面标题
        uni.setNavigationBarTitle({
          title: page.params.title
        });
        // 设置navbar标题、颜色
        uni.setNavigationBarColor({
          frontColor: page.style.titleTextColor === 'white' ? '#ffffff' : '#000000',
          backgroundColor: page.style.titleBackgroundColor
        })
      },

    },

    /**
     * 下拉刷新
     */
    onPullDownRefresh() {
      // 获取首页数据
      this.getPageData(() => {
        uni.stopPullDownRefresh()
      })
    },

    /**
     * 分享当前页面
     */
    onShareAppMessage() {
      const app = this
      const { page } = app
      return {
        title: page.params.share_title,
        path: "/pages/index/index?" + app.$getShareUrlParams()
      }
    },

    /**
     * 分享到朋友圈
     * 本接口为 Beta 版本，暂只在 Android 平台支持，详见分享到朋友圈 (Beta)
     * https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
     */
    onShareTimeline() {
      const app = this
      const { page } = app
      return {
        title: page.params.share_title,
        path: "/pages/index/index?" + app.$getShareUrlParams()
      }
    }

  }
</script>

<style lang="scss" scoped>
   page{
		background:#F5F5F5!important;
	}
  .container {
    background: #F5F5F5;
  }
  .top-localtion{
	  margin:30rpx 30rpx 0 30rpx;
	  background:#FFFFFF;
	  padding:20rpx 30rpx 20rpx 30rpx;
	  border-radius:12rpx;
	  box-shadow: 4px 4px 8px 0px rgba(240, 239, 244, 100);
	  .dwtext{
		  margin-left:10rpx;
		  color: #101010;
		  font-size:28rpx;
	  }
  }
  .box1{
	 background:#FFFFFF;
	 text-align:center;
	 padding:20rpx 0 20rpx 0;
	 margin:30rpx;
	 font-size:24rpx;
	 border-radius:20rpx;
	 box-shadow: 4px 4px 8px 0px rgba(240, 239, 244, 100);
	 border:#F1F1F1 1px solid;
  }
  .box5{
  	 background:#FFFFFF;
  	 text-align:center;
	 display: flex;
	 padding:40rpx 0 40rpx 40rpx;
	 font-size:32rpx;
	 border-radius:20rpx;
	 vertical-align: middle;
	 line-height:120rpx;
	 box-shadow: 4px 4px 8px 0px rgba(240, 239, 244, 100);
	 .tcctext{
		 margin-left:20rpx;
	 }
  }
  .iconbox{
	  width:120rpx;
	  height:120rpx;
  }
  .box0{
	  margin:30rpx 0 30rpx 30rpx;
	  width:44%;
	  float: left;
  }
  .title1{
	  text-align:center;
	  padding:10px;
	  font-weight:bold;
  }
  .title2{
	  text-align:center;
	  margin-left:100rpx;
  }
  .title3{
	  font-size:60rpx;
	  padding:50rpx 0 50rpx 0;
  }
  .title4{
  	  font-size:24rpx;
	  color:#666;
  }
  .title5{
  	  font-size:24rpx;
	  color:#666;
  }
  .color0{
	  color:#80C088;
  }
  .color1{
  	  color:#101010;
  }
  .color2{
  	  color:#101010;
  }
  .color3{
  	  color:#E0CE31;
  }
  .loutitlebox{
	  border-bottom:1px solid #F5F5F5;
	  margin:0rpx 30rpx 0rpx 30rpx;
	  padding-bottom:15rpx;
  }
  .lineheight{
	  height:120rpx;
	  width:100%;
	  color:#FFFFFF;
	  border-left:1px solid #F5F5F5;
	  margin:20rpx auto 0 auto;
  }
  .louinfo{
	  display:flex;
	  margin-left:4rpx;
	  font-size:28rpx;
  }
  .louicon{
	  width:40rpx;
	  height:40rpx;
  }
  .sexbox{
	  text-align:center;
  }
  .sexicon{
	  width:50rpx;
	  height:50rpx;
  }
  .kongxian{
	  color:#05B61D;
	  font-size:26rpx;
  }
  .zhanwei{
	  color:#BCB6B6;
	  margin-top:12rpx;
	  font-size:26rpx;
  }
  .loadtext{
	  text-align:center;
	  padding:30rpx 0 50rpx 0;
	  font-size:24rpx;
	  color: #999;
  }
</style>
